package cate.game.play.skill.passive.fairy;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

import java.util.Comparator;

/**
 * 回合开始前随机对2个目标附加【腐蚀】2回合(优先未腐蚀目标)
 */
public class 酒剑仙灵器PH extends PassiveHandler {

	private int 人数;

	private int 腐蚀buff;

	//人数=？？腐蚀buff=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		人数 = args.getInt("人数", 0);
		腐蚀buff = args.getInt("腐蚀buff", 0);
	}

	@Override
	public void onRoundBegin(ActionCtx action) {
		if(skill.owner.isDead()){
			return;
		}
		action.getTeamVs().getEnemyTeam(skill.owner.team).getFightersAlive(true).
				stream().sorted(Comparator.comparing(fighter -> fighter.buff.containTid(腐蚀buff))).
				limit(人数).forEach(fighter -> fighter.buff.tryAddByTid(action, skill.owner, 腐蚀buff));
	}
}
